import { isHasPower } from "@/assets/directives/tools";
import partyList from "./partyList";
import partyReview from "./partyReview";
import { tabPower } from "./store";
import { partyTabDict } from "./dict";
export default defineComponent({
  components: {
    partyList,
    partyReview,
  },
  setup(props, { attrs, emit, expose, slots }) {
    tabPower[0] = isHasPower("societyApi.query");
    tabPower[1] = isHasPower("societyApi.queryAudit");
    const _self: any = getCurrentInstance();
    const tabIndex = ref(1);
    const onChange = (key: string) => {
      nextTick(() => {
        _self.refs[`ref_${key}`]?.initPage?.();
      });
    };
    watch(
      () => sysZone.value,
      () => _self.refs[`ref_${tabIndex.value}`]?.initPage?.()
    );
    onActivated(() => _self.refs[`ref_${tabIndex.value}`]?.initPage?.());
    return () => (
      <>
        <a-tabs
          v-model:activeKey={tabIndex.value}
          onChange={onChange}
          style="background-color: #fff;padding-left: 10px;"
          class="s-page-tabs"
        >
          {partyTabDict.value.map(({ label, value }) => (
            <a-tab-pane key={value} tab={label}>
              {value === 1 ? (
                <partyList ref="ref_1" />
              ) : (
                <partyReview ref="ref_2" />
              )}
            </a-tab-pane>
          ))}
        </a-tabs>
      </>
    );
  },
});
